<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>
<spring:message  code="pim"/> - <spring:message  code="homepage.project"/>&nbsp;
<c:out value="${bean.project.name}"></c:out> - <spring:message  code="title.project.workspace.tab.documents"/>     
</title>	
<link href="<%= request.getContextPath() %>/css/custom.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/style.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/v.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/document.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.6.2.js"></script>
<%@include file="script/pim-util.jsp" %>
</head>
<body>
<c:if test="${bean.isSigned == true}">
<div id="all">
	<div id="wrapper">
		<div id="mainheader">
			<jsp:include page="include/common/headerSignedIn.jsp" />
		</div> 
		<div id="content-wrapper">
			<div id="top-menu">
			    <jsp:include page="include/common/topMenuHome.jsp" />
			</div>
			<div class="workspace-menu-top">
			    <c:choose>
				    <c:when test="${bean.isAdmin == true}">
				      <jsp:include page="include/common/admin-menu.jsp" />
				    </c:when>
				    <c:otherwise>
				      <jsp:include page="include/common/user-menu.jsp" />
				    </c:otherwise>
   				</c:choose> 
			</div> 			
			<div class="tabs-content v-row">
			   <div class="v-row" style="padding-top: 10px;">
			      <div class="v-row-left">
			        <b style="margin-left: 10px;" class="v-title"><spring:message  code="title.project.workspace.tab.documents"/></b>
			      </div>
			      <c:if test="${bean.isAdmin == true}">
					<div align="right" class="new-manage-org-action-head">
						<a class="new-manage-org-link" 
						   href="handleDocument.htm?pnum=${bean.project.number}&cmd=add"> + <spring:message  code="add.document"/></a>						 						
					</div>
				  </c:if>		
			   </div>
			   			   
		        <c:forEach var="document" items="${bean.documents}">
		        <div style="padding: 10px;">
				   <h3>${document.resourceCategory.name}</h3>
				    <c:forEach var="resource" items="${document.resources}">
					   <h4>
					     <a style="text-decoration: none;" href="resourceDetail.htm?pnum=${bean.project.number}&id=${resource.resourceId}">${resource.title}</a>
					     <c:if test="${bean.isAdmin == true}">
					      &nbsp;
						  <span class="v-bt-edit">
							  <a href="handleDocument.htm?pnum=${bean.project.number}&id=${resource.resourceId}&cmd=edit" 
							      class="v-link" ><spring:message code="button.edit" />
							   </a>
						  </span>						 
		                 </c:if>
					   </h4>
					   <p><em style="color: #888888;"><fmt:formatDate pattern="yyyy-MM-dd hh:mm" value="${resource.lastUpdated}"/></em></p>
					   <div class="wiki">
					     <p>
					     <c:choose>
							<c:when test="${fn:length(resource.description) > 200}">
								<c:out value="${fn:substring(resource.description, 0, 200)}..." escapeXml="false" />
							</c:when>							
							<c:otherwise>
								<c:out value="${resource.description}" escapeXml="false"></c:out>
							</c:otherwise>
					    </c:choose>
					    </p>					  			         
		               </div>
                   </c:forEach>
                </div>
    			</c:forEach>		        		        			                  
			</div>
		</div>
		<div class="footer">
			<jsp:include page="include/common/footer.jsp" />
		</div>
    </div>
</div>
</c:if>
</body>
</html>